require 'watir'
include Watir
require 'test/unit'
require 'test/unit/ui/console/testrunner'
require 'watir/testUnitAddons'
require 'watir/testcase'
require 'watir/contrib/enabled_popup'
class TC_Photos < Test::Unit::TestCase
  def test_13
    gallery = "aaaaaaxxxxvbbee"
    $ie.goto($UniVar)
    $ie.refresh()
    
    $ie.link(:text, 'Control Panel').click
    $ie.link(:text, 'Administration').click
    $ie.table(:index, 5).click
    $ie.link(:index, 13).click
    $ie.text_field(:index, 1).value = gallery
    $ie.text_field(:index, 2).value = gallery
    $ie.link(:text, 'Save').click
    $ie.link(:text, 'Exit Control Panel and Return to Site').click
    
    $ie.link(:text, 'Photos').click
    $ie.link(:text, gallery).click
    $ie.link(:text, 'add picture').click
    $ie.button(:caption, 'Upload Photo').click
  
    $PostSubject = "Aaaaa Subject"
    $ie.frame(:index, 16).text_field(:id, /FriendlyName$/).value = $PostSubject
    
    $ImagePath = "C:\\Program Files\\Telligent\\Community Server 2.1\\Web\\Emoticons\\emotion-1.gif"
    $ie.frame(:index, 16).fileField(:name, /AttachmentData$/).set($ImagePath)
    $ie.frame(:index, 16).link(:text, "Upload").click
    $ie.text_field(:index, 2).value = "lots of emoticons"
    temp_var = "Photo Subject"
    $ie.ie.Document.parentWindow.execScript("tinyMCE.getInstanceById(tinyMCE.getEditorId('mce_editor_0')).execCommand('mceSetContent', false, '" + temp_var + "')")
    $ie.link(:text, 'Save').click
    assert($ie.image(:alt, 'lots of emoticons').exists?)
    
    $ie.link(:text, 'Control Panel').click
    $ie.link(:text, 'My Photos').click
    $ie.table(:index, 7).click
    $ie.link(:text, 'All Photos').click
    $ie.refresh()
    $ie.refresh()
    $ie.link(:text, 'Delete').click_no_wait
      hwnd = $ie.enabled_popup(20)
      if(hwnd)
      w = WinClicker.new
      w.clickWindowsButton_hwnd(hwnd, "OK")
      end
    $ie.refresh()
    assert(!$ie.link(:text, 'Aaaaa Subject').exists?)
    
    $ie.link(:text, 'Administration').click
    $ie.table(:index, 5).click
    $ie.link(:index, 15).click
    $ie.link(:text, 'Delete').click_no_wait
      hwnd = $ie.enabled_popup(20)
        if(hwnd)
        w = WinClicker.new
        w.clickWindowsButton_hwnd(hwnd, "OK")
        end     
    assert(!$ie.link(:text, gallery).exists?)
  end
end